import logging
import time
# logging.basicConfig(format='%(name)s %(asctime)s %(levelname)s %(message)s',level=logging.DEBUG)
# logging.debug("debug message")
logger=logging.getLogger('log')
str_now=time.strftime('%Y-%m-%d',time.localtime())
fh=logging.FileHandler(rf'D:\io\{str_now}'+'.log')
ch=logging.StreamHandler()
fm=logging.Formatter('%(name)s %(asctime)s %(levelname)s %(message)s')
fh.setFormatter(fm)
ch.setFormatter(fm)
logger.addHandler(fh)
logger.addHandler(ch)
logger.setLevel(level=logging.DEBUG)
logger.info('message')
logger.removeHandler(fh)
logger.removeHandler(ch)
fh.close()
ch.close()